<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/js/erp/ajaxSessionTimeOut.js"></script>
<script type="text/javascript">
$(function() {
     parent.$.messager.progress('close');
     $('#form').form({
         url : contextPath+"/user/editUser.action",
         onSubmit : function() {
             parent.$.messager.progress({
                 title : '提示',
                 text : '数据处理中，请稍后....'
             });
             //检查Form参数合法性,返回false不提交
            if(!checkForm()){
                parent.$.messager.progress('close');
                 return false;
             }
         },
         success : function(data) {
             parent.$.messager.progress('close');
             data =JSON.parse(data);
             if(data && "success" == data.result){
            	 parent.$.messager.alert('提示信息', data.msg, 'info');
            	 parent.$.modalDialog.handler.dialog('close');
           	     parent.$.modalDialog.openner_dataGrid.datagrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_dataGrid这个对象，是因为user.jsp页面预定义好了
             } else {
                 parent.$.messager.alert('错误', data.msg, 'error');
             }
         }
     });
});

function checkForm(){
	var checkLoginNameUrl = contextPath + "/user/checkLoginName.action";
    var isValid = true;
    var loginName = $("#form").find("[name='loginName']").validatebox({
        required: true,
        validType:['length[1,100]','remoteValid[\''+checkLoginNameUrl+'\',\'loginName\',\'输入的账号已存在\',\'${user.loginName}\']']
    });
    isValid = isValid && loginName.validatebox('isValid');
    var realName = $("#form").find("[name='realName']").validatebox({
        required: true,
        validType:['length[1,100]']
    });
    isValid = isValid && realName.validatebox('isValid');
    var email = $("#form").find("[name='email']").validatebox({
        required: true,
        validType:['length[1,100]','email']
    });
    isValid = isValid && email.validatebox('isValid');
    
    return isValid;
}
</script>
<!-- edit-dialog begin -->
<div class="edit-user-context">
   <div class="p5">
        <form id="form" method="post">
           <input id="userId" name="id" type="hidden" value="<s:property value='user.id'/>"/>
           <ul class="fn-clear" style="margin-left: 40px;"> 
              <li class="fl"> 
                  <label for="loginName" class="fl pt3 pl15">账号：</label> 
                  <input name="loginName" class="span2" type="text" value="<s:property value='user.loginName'/>"/>
              </li>
              <li class=""> 
                  <label for="realName" class="fl pt3 ml86">名字：</label> 
                  <input name="realName" class="span2"  type="text" value="<s:property value='user.realName'/>"/>
              </li>
              <li class="fl"> 
                  <label for="status" class="fl pt3 pl15">状态：</label>
                  <select id="status-combobox" name="status" class="easyui-combobox span2" style="height: 26px;line-height: 26px;" data-options="editable:false">  
                      <option value="1" <s:if test="user.status eq 1">selected="selected"</s:if>>正常</option>  
                      <option value="2" <s:if test="user.status eq 2">selected="selected"</s:if>>锁定</option>  
                  </select> 
              </li>
              <li class="">
                  <label for="email" class="fl pt3 ml60">邮件地址：</label> 
                  <input name="email" class="span2" type="text" value="<s:property value='user.email'/>"/> 
              </li>
              <li class="">
                 <label for="description" class="fl pt3" style="margin-left: -12px;">描述信息：</label> 
                 <textarea name="description" class="" style="height: 80px;overflow: auto;line-height: 18px;width: 395px;"><s:property value='user.description'/></textarea>
               </li>
           </ul>
           <div class="fn-clear"></div>
       </form>
   </div>
</div> 
<!-- edit-dialog end -->